<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <meta charset="UTF-8"/>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <title>Title</title>
</head>

<body>
<div class="search-block">
    <button id="searchButton" name="searchButton" onclick="retrieveGuests02()" type="button">begin</button>
    <button id="stop" name="searchButton" onclick="stop()" type="button">stop</button>
</div>
<div id="resultsBlock" style="height: 100%">

</div>
</body>

<script>
    //
    var start = true
    var i = 1
    var x = function retrieveGuests() {
        var url = '/data';
        console.log(i++)
        $("#resultsBlock").load(url);

    }

    function startTask() {
        var url = '/start';
        $("#resultsBlock").load(url);
    }

    var interval
    function retrieveGuests02() {
        if (start) {
            startTask();
            start = false
            console.log("setInterval")
             interval = setInterval(x, 200);
        }
    }

   function  stop(){
       window.clearInterval(interval)
       var url = '/stop';
       $("#resultsBlock").load(url);
       start=true
   }
</script>

</html>